﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/gif" href="~/img/animated_favicon1.gif">
    <link href="~/UILibs/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/UILibs/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Css/css.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.jqprint-0.3.js"></script>
    <script src="~/UILibs/easyui/jquery.easyui.min.js"></script>

    <script src="~/UILibs/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/datagrid-detailview.js"></script>
    <title></title>
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
    <script type="text/javascript">
        $(function () {

            $('#txtDate2').datebox({
                onSelect: function () { searchData() }
            });
            $("#data").datagrid({
                fit: true,
                title: '用户意见反馈统计',
                striped: true,
                rownumbers: true,
                columns:// //feedbackId  feedbackValue  feedbackTime wechatCode userName wechatName
                    [[
                            { field: 'feedbackId', title: '编号', width: 80, halign: 'center', align: 'center', sortable: true },
                            { field: 'userPhone', title: '手机号', width: 250, halign: 'center', align: 'center' },
                            { field: 'userCode', title: '微信编号', width: 180, halign: 'center', align: 'center' },
                            { field: 'wechatName', title: '微信名称', width: 180, halign: 'center', align: 'center' },
                            { field: 'userName', title: '客户姓名', width: 120, halign: 'center', align: 'center', },
                            { field: 'feedbackTime', title: '反馈时间', width: 180, halign: 'center', align: 'center', sortable: true },
                            { field: 'feedbackValue', title: '反馈建议', width: 300, halign: 'center', },
                            {
                                field: 'IsReply', title: '操作', width: 100, align: "center", formatter: formatOper
                            }
                            //{
                            //    field: 'OPERATE', title: '操作', width: 100, align: "center", 
                            //}
                    ]],
                singleSelect: true,
                loadMsg: '正在加载数据,请耐心等待.......',
                url: pageConfig.getAction,
                queryParams: {
                    date1: $('#txtDate1').val(),
                    date2: $('#txtDate2').val(),
                },
                pagination: true,
                pageSize: 25,
                pageList: [25, 30, 35],
                sortName: 'feedbackId',
                sortOrder: 'desc',
                toolbar: '#tool',
            });
            $("#formdialog").dialog({
                width: 400,
                height: 250,
                closed: true,
                modal: true,
                buttons: '#btns'
            });
        });

        var pageConfig = {
            getAction: '@Url.Action("GetNotice")',
            modifyAction: '@Url.Action("ModifyReply")',

        };
        // 回复按扭
        function formatOper(val, row, index) {
            // alert(val);
            if (val == 0) {
                return "<a href='#' style='color:red' onclick=alertFormDialog(" + row.userCode + ")>点击回复</a>";
            }
            if (val == 1) {
                return "<a href='#' style='color:gray'  onclick=alertFormDialog(" + row.userCode + ")>已回复</a>";
            }

        }
        //弹出框
        function alertFormDialog(type) {
            $("#formdialog form").form("reset");
            $("#txtCode").val(type);
            $("#formdialog").dialog("open");
            $("#formdialog").dialog("setTitle", "添加");
            $('#txtCode').attr("disabled", true);//不可编辑

        }
        //点击保存按钮 
        function save() {
            var a = $("#txtNotice").val();  //可以获取到
            if ($("#txtNotice").val() != null && $("#txtNotice").val() != "") {
                var bool = $("#fm").form("validate");
                if (bool) {
                    var rows = $("#data").datagrid("getSelections");
                    var data;
                    data = {
                        userCode: $("#txtCode").val(),
                        checkString: md5("ABCabc123"),
                        data: $("#txtNotice").val(),
                    };
                    data2 = {
                        userCode: $("#txtCode").val(),

                    };
                    $.ajax({
                        url: "http://shiyispace.com/index.php/index/index/opinionreply",
                        datatype: "JOSN",
                        data: data,
                        type: "post",
                        success: function (data2) {
                            //alert(data2.code);
                            if (data2.code == 200) {
                                $.messager.alert("成功", "回复成功", "info");
                            }
                            url = pageConfig.modifyAction;
                            $.ajax({
                                url: url,
                                dataType: "json",
                                data: { userCode: $("#txtCode").val() },
                                type: "POST",
                                beforeSend: function () {
                                    $.messager.progress({ title: "执行中", text: "" });
                                },

                            });
                        },
                        complete: function () {
                            complete();
                        }
                    });

                }
            }
        }



        //查询
        function searchData() {
            var start = $("#txtDate1").datebox('getValue');//获取时间
            var end = $("#txtDate2").datebox('getValue');
            //alert(start);
            if ((start == null || end == null) && (end == "" || end == ""())) {

                alert("开始日期和结束时间不能为空");
                txtDate1.focus();
                return false;
            }
            else if (txtDate1.value > txtDate2.value) {

                alert("开始日期不能大于截至日期！");
                $("#txtDate1").textbox('setValue');//清空文本框的值
                $("#txtDate1").textbox('clear');
                $("#txtDate2").textbox('setValue');
                $("#txtDate2").textbox('clear');

                txtDate1.focus();
                txtDate2.focus();
                return false;
            }
            else {
                $("#data").datagrid('load', {
                    date1: $('#txtDate1').val(),
                    date2: $('#txtDate2').val(),
                });
            }
        }

        function excel111() {
            window.location.href = "/Notice/ExportExcel?date1=" + $("#txtDate1").val() + '&date2=' + $('#txtDate2').val();
        }
        //取消按钮
        function closeDptDialog() {
            $("#formdialog").dialog("close")
        }

        function complete() {
            $("#data").datagrid("load");
            $.messager.progress("close");
            $("#formdialog").dialog("close");
        }
    </script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%">
    <div data-options="region:'center'" id="dataPrint">

        <table id="data" style="height: 50px"></table>

    </div>

    <div id="tool" style="padding: 30px;">
        <form id="formid" method='post' action='/OrderStatistic/Excel'>
        </form>
        <div>
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
               日期：<input id="txtDate1" type="text" class="easyui-datebox" onchange="searchData()" />
            -- 
                <input id="txtDate2" type="text" class="easyui-datebox" onchange="searchData()" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
            <a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData();">查询</a>

        </div>

    </div>
    <div id="formdialog">
        @using (Ajax.BeginForm(new AjaxOptions
        {
            OnBegin = "before",
            OnComplete = "complete",
            OnSuccess = "success",
            OnFailure = "error",
            HttpMethod = "Post"
        }))
        {
            <div class="dialog-table">
                <form id="fm" method="post">


                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tk_table">
                        <tr>
                            <td>用户编号：</td>

                            <td class="white-tr" style="text-align: center; margin-bottom: 0; padding-bottom: 0;">
                                <input type="text" id="txtCode" /></td>

                        </tr>
                        <tr>
                            <td>回复内容：</td>

                            <td class="white-tr" style="text-align: center; margin-bottom: 0; padding-bottom: 0;">
                                <textarea cols="25" id="txtNotice" class="easyui-validatebox" style="margin-bottom: 0; padding-bottom: 0;" rows="5" data-options="required:true"></textarea></td>

                        </tr>

                    </table>
                </form>
            </div>
        }
    </div>

    <div id="btns">
        <div style="margin-bottom: 10px">
            <a class="easyui-linkbutton" iconcls="icon-redo" onclick="closeDptDialog()">取消</a>
            <a class="easyui-linkbutton" iconcls="icon-add" onclick="save()">保存</a>
        </div>
    </div>
    <style>
        #dataPrint.datagrid-btable tr {
            height: 50px;
        }
    </style>
</body>
</html>
